package com.qf.zyh.services.Impl;

import com.qf.zyh.dao.CategoryMapper;
import com.qf.zyh.dao.EntryMapper;
import com.qf.zyh.entity.EdocCategory;
import com.qf.zyh.entity.EdocEntry;
import com.qf.zyh.services.EntryServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class EntryServicesImpl implements EntryServices {
    @Autowired
    private EntryMapper em;
    @Autowired
    private CategoryMapper cm;

    @Override
    public Map<String, Object> getAll() {
        List<EdocEntry> all = em.getAll();
        List<EdocCategory> all1 = cm.getAll();
        Map<String, Object> map = new HashMap<>();
        map.put("eent",all);
        map.put("ecat",all1);
        return map;
    }

    @Override
    public Map<String, Object> getByName(String name) {
        List<EdocEntry> all = em.getByName(name);
        List<EdocCategory> all1 = cm.getAll();
        Map<String, Object> map = new HashMap<>();
        map.put("eent",all);
        map.put("ecat",all1);
        return map;
    }

    @Override
    public EdocEntry getById(Integer id) {
        EdocEntry byId = em.getById(id);
        if (byId!=null) {
            return byId;
        }
        return null;
    }

    @Override
    public int addEntry(EdocEntry ee) {
        int i = em.addEntry(ee);
        return i;
    }

    @Override
    public int updaEntry(EdocEntry ee) {
        int i = em.updaEntry(ee);
        return i;
    }

    @Override
    public int delById(int id) {
        int i = em.delById(id);
        return i;
    }

}
